<?php

    namespace App\Admin\Tools\Finance;

    use App\Models\ContractedCustomerModel;
    use App\Models\FinanceExpensesModel;
    use Encore\Admin\Grid\Tools\AbstractTool;

    class ExpenseEditTool extends AbstractTool
    {
        private int $id;

        public function __construct(int $id)
        {
            $this->id = $id;
        }

        /**
         * @inheritDoc
         */
        public function render()
        {
            return view('finance.expense_edit', [
                'id' => $this->id,
                'customer' => (new ContractedCustomerModel)->customerSelect(),
                'data' => FinanceExpensesModel::query()->where('id', $this->id)->first()
            ]);
        }

        public function __toString() {
            // 确保这里返回一个字符串
            return "";
        }
    }
